<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>ES11</title>
	</head>
	<body>
		<script>
			class Person {
				// 公有属性
				name;
				// 私有属性
				#age;
				#weight;
				
				constructor(name,age,weight) {
					this.name = name;
					this.#age = age;
					this.#weight = weight;
				}
				show() {
					console.log(this.name);
					console.log(this.#age);
					console.log(this.#weight);
				}
			}
			
			const girl = new Person('xh',26,'65kg');
			girl.show();
			// Promise.allSettled
			const p1 = new Promise((resolve,reject) => {
				setTimeout(() => {
					resolve('num - 1');
				},1000);
			});
			const p2 = new Promise((resolve,reject) => {
				setTimeout(() => {
					resolve('num - 2');
					//reject('error......');
				},1000);
			});
			const rs = Promise.allSettled([p1,p2]);
			console.log(rs);
			const rs2 = Promise.all([p1,p2]);
			console.log(rs2);
			// String.matchAll
			let str = `<ul>
				<li>
					<a>AAA</a>
					<p>1994-09-10</p>
				</li>
				<li>
					<a>BBB</a>
					<p>1994-07-06</p>
				</li>
			</ul>`;
			const reg = /<li>.*?<a>(.*?)<\/a>.*?<p>(.*?)<\/p>/sg;
			const rs3 = str.matchAll(reg);
			// console.log(rs3);
			// for(let v of rs3) {
			// 	console.log(v);
			// }
			console.log([...rs3]);
			// 可选链操作符?.
			function main(config) {
				const dbHost = config?.db?.host;
				console.log(dbHost);
			}
			main({
				db:{
					host:'localhost',
					port:2222
				},
				cache:{
					host:'127.0.0.1',
					port:3333
				}
			});
			// BigInt 大整形 大数值运算
			let n = 5645n;
			console.log(n,typeof n);
			let max = Number.MAX_SAFE_INTEGER;
			console.log(max);
			console.log(max + 1);
			console.log(max + 2);
			
			console.log(BigInt(max));
			console.log(BigInt(max) + BigInt(1));
			console.log(BigInt(max) + BigInt(2));
			// globalThis 始终指向全局的this对象,无论是在浏览器还是nodeJs中
			console.log(globalThis);
			function t() {
				console.log(this);
				console.log(globalThis);
			}
			let x = new t();
			</script>
	</body>
</html>